package com.mstf.cashier.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.mstf.cashier.entity.Score_discount;

public class Score_discountDAO {
	ResultSet rs=null;
	String sql;
	
	@SuppressWarnings("static-access")
	public Score_discount queryByscore(int score){
		sql="select min(discount) from (select discount from score_discount where min_score<=?) n";
		Object[] params={score};
		rs=new DBManager().query(sql, params);
		Score_discount sd=new Score_discount();
		try {
			while(rs.next()){
				
				 sd.setDiscount(rs.getFloat(1));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally{
			new DBManager().closeCon(null);
		}
		return sd;
		
	} 
	
	/*public static void main(String [] args){
		new Score_discountDAO().queryByscore(0);
	} */
}